import request from '@/utils/request'

export function renderHoliday($this) {
  console.log("renderHoliday....")
  listHolidayOfMonth($this.queryParams).then(response => {
    const data = response.data;
    renderTable($this, data);
  });
}

export function listHolidayOfMonth(query) {
  return request({
    url: '/business/holiday/list-of-month',
    method: 'get',
    params: query
  })
}


/**
 * 需要 this 指定了 "form" ， ref="form"
 * @param $this
 * @param data
 */
function renderTable($this, data) {
  console.log("data.weekends ...... ", JSON.stringify(data.weekends))
  const rows = $this.$refs.form.$el.querySelectorAll("tr");
  // 只处理第一行表头
  const rowCells = rows[0].querySelectorAll("th");
  rowCells.forEach((cell, index) => {
    if(data.weekends.includes(index)) {
      cell.style.backgroundColor = "#b4d7eb";
    } else {
      // 还原处理
      cell.style.backgroundColor = "#f8f8f9";
    }
  });
}
